<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/8/21 0021
 * Time: 14:01
 */
namespace app\admin\controller;

use think\Controller;
use think\Session;

class Login extends Controller
{
    private $_model;

    public function _initialize(){
        $this->_model = new \app\admin\model\Login();
    }

    /**
     * 登录验证
     * @return mixed|void
     */
    public function login(){
        if(request()->isPost())
        {
            $check = $this->_model->login();
            if($check['error']==0)
            {
                return $this->success('登录成功', url('Admin/index'), '', 1);
            }else{
                return $this->error($check['msg'], url('Login/Login'),'1333',1);
            }
        }else{
            return $this->fetch('login');
        }

    }

    /**
     * 退出登录
     */
    public function loginout()
    {
        Session::clear();
        $this->success('注销成功', url('login/login'), '', 1);
    }
}